#pragma once
#include "Entity.h"
#include "Struct.h"

enum class MarkerType { ALC, SQ_ALC, LDW, DCLC, ACC_TG, ACC_FD, TailLamp, RoadBg, ZhicheCircle, ACC_Circle };

class MarkerEntity : public Entity {
public:
	MarkerEntity(MarkerType type) { create(type); }

	MarkerEntity(MarkerType type, int boundModelID) { create(type, boundModelID); }

	void create(MarkerType type);
	void create(MarkerType type, int boundModelID);

	EntityType type() const override { return EntityType::MARKER; }
	RenderOrder renderOrder() const override { return m_renderOrder; }

private:
	MarkerEntity(Entity* parent): Entity(parent), m_renderOrder(parent->renderOrder()) {}

	void createALC(RenderOrder order);
	void createSQ_ALC(RenderOrder order);
	void createLDW(RenderOrder order);
	void createDCLC(RenderOrder order);
	void createACC_TG(RenderOrder order);
	void createACC_FD(RenderOrder order, int boundModelID);
	void createTailLamp(RenderOrder order);
	void createRoadBg(RenderOrder order);
	void createBreathCircle(RenderOrder order, const P& modelPos = P());

	void createAccTGRects(int i, CVector<P>& vertices, CVector<UInt>& indices);
	void createTailLampLight(const CColor& color, HDir hdir, bool asChild = false);
	void createLineEllipse(const LineEq& eq, const CColor& color, HDir hdir);

	enum { ASCHILD = 1 };
	Entity* install(const CString& shaderName, PrimitiveType primitiveType, const CVector<P>& vertices, float vertex2dY, const CColor& color, bool asChild = false);
	Entity* install(const CString& shaderName, PrimitiveType primitiveType, const CVector<P>& vertices, float vertex2dY, const CVector<UInt>& indices, const CColor& color, bool asChild = false);
	Entity* install(const CString& shaderName, PrimitiveType primitiveType, const CVector<Vec3>& vertices, const CColor& color, bool asChild = false);
	Entity* install(const CString& shaderName, PrimitiveType primitiveType, const CVector<Vec3>& vertices, const CVector<UInt>& indices, const CColor& color, bool asChild = false);
	
	Entity* toInstall(const CString& shaderName, PrimitiveType primitiveType, const CVector<P>& vertices2d, float vertex2dY, const CVector<Vec3>& vertices3d, const CVector<UInt>& indices, const CColor& color, bool asChild);

	RenderOrder m_renderOrder = RenderOrder::INVALID;
};